<?php
require '../config.php';
$resultset = mysql_query($_REQUEST['query'],$conexion);
$sum = $_REQUEST['sum'];
if(!$resultset)
{
    mysql_close();
    echo json_encode('error en el query: ' . mysql_error());
}
elseif(!mysql_num_rows($resultset))
{
    mysql_close();
    echo json_encode('Sin resultados');
}
else
{
	?>
			
			<button type="button" class="btn btn-default" onclick="reportarpdf();" >Imprimir <span class= 'glyphicon glyphicon-print'></span>  </button>
					<?php
	        
			echo   "<table class='table table-bordered'>";
			
			echo   "<tr>";
			echo   "<th>Id Pago</th><th>Cliente</th><th>C&eacute;dula</th><th>Fecha</th><th>Monto</th><th>Id Usuario</th><th>Usuario</th>";
			echo   "</tr>";
			echo   "<tbody>";
			$aux=0;
			while($row = mysql_fetch_assoc($resultset))
			{
				if($aux==0){
					$color="#FFFFFF";
					$aux=1;
				}else{
					$color="#F9F9F9";
					$aux=0;
				}
				echo ("<tr bgcolor='".$color."'>");
				echo   "<td>".$row['idregpagos']."</td>";
				echo   "<td>".$row['nombres']." ".$row['apellidos']."</td>";
				echo   "<td>".$row['cedula']."</td>";
				
				echo   "<td>".date("d M Y h:m:s",strtotime($row['fecha']))."</td>";
				
				if($sum == "true")
					echo   "<td>$ ".$row['SUMATORIA']."</td>";
				else 
					echo   "<td>$ ".$row['monto']."</td>";
				
				echo   "<td>".$row['idusuarios']."</td>";
				echo   "<td>".$row['nombre']." ".$row['apellido']."</td>";
				echo   "</tr>";
			}
			echo   "</tbody>";
			echo   "</table>";
			mysql_close();
			
			
}

?>